
#include "func_test.h"


TEST_FUN_START(load)
	li.d $r12, 0x1234

	dbar 0

_test_atomic:
    la.abs $r11, atomic
    li.d $r12, 0x1234
    li.d $r13, 0xf1f1
    li.d $r14, 0x8
    st.d $r12, $r11, 0
    stx.d $r12, $r11, $r14

    amswap.w $r20, $r13, $r11
    amswap.d $r20, $r13, $r11

    addi.w      $t1, $zero, 1
    amadd_db.w  $t0, $t1, $r11

    dbar 0

    ld.d $r13, $r11, 0
    add.d      $r13, $r13, $zero

    amswap_db.w $r20, $r13, $r11
    amswap_db.d $r20, $r13, $r11

    st.d $r12, $r11, 0

    ammax.w $r20, $r13, $r11
    ammax.d $r20, $r13, $r11

    ammax_db.w $r20, $r13, $r11
    ammax_db.d $r20, $r13, $r11


_test_llsc:
    li.d $r13, 0xf1
    li.d $r14, 0xf0
    
    la.abs $r11, ll_sc

    ll.d $r15, $r11, 0

    ld.d $r14, $r11, 0

    sc.d $r13, $r11, 0

    add.d $r13, $r13, $zero

TEST_FUN_END(load)


    .globl  atomic
    .section        .data,"aw",@nobits
    .align  3
    .type   atomic, @object
    .size   atomic, 8
atomic:
    .space  8

    .globl  ll_sc
    .section        .data,"aw",@nobits
    .align  3
    .type   ll_sc, @object
    .size   ll_sc, 8
ll_sc:
    .space  8



